<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" href="../lib/bootstrap.min.css">
	<link rel="stylesheet" href="../lib/verify.css">
	<link rel="stylesheet" href="../css/main.css">
	<script src="../lib/jquery-3.3.1.js"></script>
	<script src="../js/application.js"></script>
	<script src="../layui/layui.js"></script>
	<script src="../lib/jquery.params.js"></script>
	<script src="../lib/bootstrap.js"></script>
	<script src="../lib/verify.min.js"></script>
</head>
<body>

    <div class="navbar-default"style="height:25px;">
        <div class="container" >
           
        </div>
    </div>

<div class="container container-small">
    <h1>
        注册 <small>已有账号? <a href="login.html">登录</a></small>
    </h1>
    <form action="">
        <div class="form-group">
            <label for="">手机</label>
            <input type="text" class="form-control" id="phone">
        </div>
        <!-- <div class="form-group">
            <label for="">验证码</label>
            <div class="input-group">
                <input type="text" class="form-control">
                <div class="input-group-btn">
                    <div class="btn btn-default">获取验证码</div>
                </div>
            </div>  
        </div> -->
        <div class="form-group">
            <label for="">密码</label>
            <input type="password" class="form-control" id="password">
        </div>
        <div class="form-group">
            <label for="">再次输入密码</label>
            <input type="password" class="form-control" id="password2">
        </div>
        <div class="form-group">
            <button type="button" class="btn btn-primary btn-block" id="register">注册</button>
        </div>
        <div class="form-group">
            
        </div>
    </form>
</div>

<div class="footer">

</div>
</body>

<script>
    var register = function () {
		var phone = $("#phone").val();
		var password = $("#password").val();
        var password2 = $("#password2").val();
		layui.use(['layer'], function () {

			$ = layui.$
				, layer = layui.layer
			if (phone == "" || phone == undefined) {
				layer.msg("账号未输入");
				return
			}
			if (password == "" || password == undefined) {
				layer.msg("密码未输入");
				return
			}
            if (password !=password2 || password2 == undefined) {
				layer.msg("两次密码不一致");
				return
			}
			showloading(true);
			$.ajax({
				url: urlapi + 'user/addUserByPhone',
				data: { phone: phone, password: password },
				type: "Post",
				dataType: "json",
				success: function (data) {
					showloading(false);
					if (data.code == -9999) {
						layer.msg(data.msg);
					} else {
						layer.msg("注册成功");
						setTimeout(function () {
							$(location).attr('href', 'index.html');
						}, 1000);

					}
				},
				error: function () {
					showloading(false);
					layer.msg('网络异常');
				}
			});
		})
	}
	$("#register").on("click", register)
</script>
</html>